* Replication File
* Judicial Instability and Endogenous Constitutional Change: Lessons from Latin America
* Anibal Perez-Linan and Andrea Castagnola
* British Journal of Political Science
* Jan 17 2014

clear matrix
clear
clear mata
cd "C:\Users\asp27\Documents\1_Research\Research in Progress\Courts\PAPERS\Institutional_reform\2_version2\BJPOLS\replication"
use "BJPolS.dta", clear


/* TABLE 2 : First stage */

* 2.1 New Constitution
  logit newc pchange1 pchange2 transition breakdown freelec polity2 presalign partyalign constage amendage judrev jct cjexit pgdp_1 gpgdp_1 t /// /* Included instruments */
		     supermaj federal bicameral dcchange dcamend rspain cjnfixed jn0 djnreg [pweight=ctryearw]                                            /* Excluded instruments */
estimates store reg21
predict   newc_hat, xb
label var newc_hat "Replacement Instrumented" 
lincom  pchange1+pchange2       /* Effect of new party in the Executive */
lincom  judrev+jct              /* Effect of Constitutional Tribunal */

* 2.2 Amendments
  logit newa pchange1 pchange2 transition breakdown freelec polity2 presalign partyalign constage amendage judrev jct cjexit pgdp_1 gpgdp_1 t /// /* Included instruments */
		     supermaj federal bicameral dcchange dcamend rspain cjnfixed jn0 djnreg [pweight=ctryearw]                                            /* Excluded instruments */
estimates store reg22
predict   newa_hat, xb
label var newa_hat "Amendment Instrumented" 
lincom pchange1+pchange2        /* Effect of new party in the Executive */
lincom  judrev+jct              /* Effect of Constitutional Tribunal */

* 2.3 Size of the Court
  regress jn pchange1 pchange2 transition breakdown freelec polity2 presalign partyalign constage amendage judrev jct cjexit pgdp_1 gpgdp_1 t /// /* Included instruments */
		     supermaj federal bicameral dcchange dcamend rspain cjnfixed jn0 djnreg [pweight=courtyearw]                                          /* Excluded instruments */
estimates store reg23
predict   jn_hat, xb
label var jn_hat "Size Instrumented" 
lincom pchange1+pchange2      /* Effect of new party in the Executive */
lincom  judrev+jct            /* Effect of Constitutional Tribunal */

* Format Table
xml_tab reg21 reg22 reg23, save("2_table2.xls") ///
        stats(N) sheet("Table2") stars(* 0.05 ** 0.01) format((S2100) (N2202)) replace  ///
		keep(pchange1 pchange2 transition breakdown freelec polity2 presalign partyalign constage amendage judrev jct cjexit pgdp_1 gpgdp_1 t /// 
		     supermaj federal bicameral dcchange dcamend rspain cjnfixed jn0 djnreg _cons) 

 
/* TABLE 3 : Survival Models */

* 3.1 Only constitutional shift variables
  logit jexit t t2 t3 newc newa jn , or                  
estimates store reg31

* 3.2 Naive model
  logit jexit pchange1 pchange2 transition breakdown freelec polity2 presalign partyalign constage amendage judrev jct cjexit pgdp_1 gpgdp_1 t /// /* Included instruments */
              t2 t3 newc newa jn, or  
estimates store reg32
lincom judrev+jct, or
			
* 3.3 Two-Stage Prediction Substitution Model 
bootstrap, reps(100) strata(jexit jct newc newa regchange jcode) : ///
  logit jexit pchange1 pchange2 transition breakdown freelec polity2 presalign partyalign constage amendage judrev jct cjexit pgdp_1 gpgdp_1 t /// /* Included instruments */
              t2 t3 newc_hat newa_hat jn_hat, or 
estimates store reg33	
lincom judrev+jct, or		
			
* Format Table
xml_tab reg31 reg32 reg33, save("3_table3.xls") or ///
        stats(N) sheet("Table3") stars(* 0.05 ** 0.01) format((S2100) (N2202)) replace  ///
        keep(newc newc_hat newa newa_hat jn jn_hat ///
		     pchange1 pchange2 transition breakdown freelec polity2 presalign partyalign constage amendage judrev jct cjexit ///
             pgdp_1 gpgdp_1 t t2 t3 _cons)
		
* Test of exogeneity for excluded instruments in model 3.3		
  logit jexit pchange1 pchange2 transition breakdown freelec polity2 presalign partyalign constage amendage judrev jct cjexit pgdp_1 gpgdp_1 t /// /* Included instruments */
              t2 t3 newc_hat newa_hat jn_hat	
  predict   r2ndstage,  res
  pwcorr    r2ndstage supermaj federal bicameral cjnfixed jn0 dcchange dcamend djnreg rspain, sig 
  regress   r2ndstage pchange1 pchange2 transition breakdown freelec polity2 presalign partyalign constage amendage judrev jct cjexit pgdp_1 gpgdp_1 t t2 t3 /// /* Included instruments */
		              supermaj federal bicameral cjnfixed jn0 dcchange dcamend djnreg rspain                                                                     /* Excluded instruments */
 
 
/*** SUPPLEMENTARY MATERIALS ***/	

		
/* TABLE S1 : Descriptives */

sum jexit newc newa jn ///
    pchange1 pchange2 transition breakdown freelec polity2 presalign partyalign ///
    constage amendage judrev jct cjexit ///
    pgdp_1 gpgdp_1 t ///
    supermaj federal bicameral dcchange dcamend rspain ///
    cjnfixed jn0 djnreg,  separator(0)

	
/* TABLE S2 : By Regime Type */
	
* S2.1 Democracies and Semi-Democracies
bootstrap, reps(100) strata(jexit jct newc newa regchange jcode) : ///
  logit jexit pchange1 pchange2 transition breakdown freelec polity2 presalign partyalign constage amendage judrev jct cjexit pgdp_1 gpgdp_1 t /// /* Included instruments */
              t2 t3 newc_hat newa_hat jn_hat if r > 0, or 
estimates store regS21	

* S2.2 Dictatorships
bootstrap, reps(100) strata(jexit jct newc newa regchange jcode) : ///
  logit jexit pchange1 pchange2 transition breakdown freelec polity2 presalign partyalign constage amendage judrev jct cjexit pgdp_1 gpgdp_1 t /// /* Included instruments */
              t2 t3 newc_hat newa_hat jn_hat if r==0, or 
estimates store regS22	

* Format Table
xml_tab reg33 regS21 regS22, save("4_tableS2.xls") or ///
        stats(N) sheet("Table_S2") stars(* 0.05 ** 0.01) format((S2100) (N2202)) replace  ///
        keep(newc_hat newa_hat jn_hat ///
		     pchange1 pchange2 transition breakdown freelec polity2 presalign partyalign constage amendage judrev jct cjexit ///
             pgdp_1 gpgdp_1  t t2 t3 _cons)
			
			
/* TABLE S3 : Controlling for Type of Amendment */
	
* S3.1 Unfavorable reforms
bootstrap, reps(100) strata(jexit jct newc newa regchange jcode) : ///
  logit jexit pchange1 pchange2 transition breakdown freelec polity2 presalign partyalign constage amendage judrev jct cjexit pgdp_1 gpgdp_1 t /// /* Included instruments */
              t2 t3 newc_hat newa_hat jn_hat ///
              njudr nfixn nlife nterm nappt, or 
estimates store regS31		

* S3.2 Favorable reforms
bootstrap, reps(100) strata(jexit jct newc newa regchange jcode) : ///
  logit jexit pchange1 pchange2 transition breakdown freelec polity2 presalign partyalign constage amendage judrev jct cjexit pgdp_1 gpgdp_1 t /// /* Included instruments */
              t2 t3 newc_hat newa_hat jn_hat /// 
	      	  pjudr pfixn plife pterm pappt, or 
estimates store regS32		
			
* Format Table
xml_tab regS31 regS32, save("4_tableS3.xls") or ///
        stats(N) sheet("Table_S3") stars(* 0.05 ** 0.01) format((S2100) (N2202)) replace  ///
        keep(newc_hat newa_hat jn_hat ///
		     njudr pjudr nfixn pfixn nlife plife nterm pterm nappt pappt)

			 
/* TABLE S4 : Robustness */
	
* S4.1 Frailty
xtset jcode year
bootstrap, reps(100) strata(jexit jct newc newa regchange jcode) : ///
  xtlogit jexit pchange1 pchange2 transition breakdown freelec polity2 presalign partyalign constage amendage judrev jct cjexit pgdp_1 gpgdp_1 t /// /* Included instruments */
                t2 t3 newc_hat newa_hat jn_hat, or 
estimates store regS41	

* S4.2 Two-Stage Prediction Substitution with Count Model
    nbreg jn    pchange1 pchange2 transition breakdown freelec polity2 presalign partyalign constage amendage judrev jct cjexit pgdp_1 gpgdp_1 t /// /* Included instruments */
                supermaj federal bicameral dcchange dcamend rspain cjnfixed jn0 djnreg                                                               /* Excluded instruments */
    predict jn_hat2
bootstrap, reps(100) strata(jexit jct newc newa regchange jcode) : ///
    logit jexit pchange1 pchange2 transition breakdown freelec polity2 presalign partyalign constage amendage judrev jct cjexit pgdp_1 gpgdp_1 t /// /* Included instruments */
                t2 t3 newc_hat newa_hat jn_hat2, or 
estimates store regS42		

* S4.3 Two-Stage Residual Inclusion
*      New Constitution
  logit newc pchange1 pchange2 transition breakdown freelec polity2 presalign partyalign constage amendage judrev jct cjexit pgdp_1 gpgdp_1 t /// /* Included instruments */
		     supermaj federal bicameral dcchange dcamend rspain cjnfixed jn0 djnreg                                                               /* Excluded instruments */
  predict   newc_res, res
  label var newc_res "Replacement Control function"
*      Amendments
  logit newa pchange1 pchange2 transition breakdown freelec polity2 presalign partyalign constage amendage judrev jct cjexit pgdp_1 gpgdp_1 t /// /* Included instruments */
		     supermaj federal bicameral dcchange dcamend rspain cjnfixed jn0 djnreg                                                               /* Excluded instruments */
  predict   newa_res, res
  label var newa_res "Amendment Control function"
*      Size of the Court
  regress jn pchange1 pchange2 transition breakdown freelec polity2 presalign partyalign constage amendage judrev jct cjexit pgdp_1 gpgdp_1 t /// /* Included instruments */
		     supermaj federal bicameral dcchange dcamend rspain cjnfixed jn0 djnreg                                                               /* Excluded instruments */
  predict   jn_res, res
  label var jn_res   "Size Control function"

bootstrap, reps(100) strata(jexit jct newc newa regchange jcode) : ///
    logit jexit pchange1 pchange2 transition breakdown freelec polity2 presalign partyalign constage amendage judrev jct cjexit pgdp_1 gpgdp_1 t /// /* Included instruments */
                t2 t3 newc newa jn newc_res newa_res jn_res, or 
estimates store regS43	

* Format Table
xml_tab regS41 regS42 regS43, save("4_tableS4.xls") or ///
        stats(N) sheet("Table_S4") stars(* 0.05 ** 0.01) format((S2100) (N2202)) replace  ///
        keep(newc newc_hat newc_res newa newa_hat newa_res jn jn_hat jn_hat2 jn_res)
			